package com.example.project;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;

import com.example.project.entity.City;
import com.example.project.entity.Data;
import com.example.project.entity.DataList;
import com.example.project.service.ConDataManager;

import java.util.List;

public class Main2Activity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        CondAapter condAapter=  new  CondAapter(ConDataManager.root.getData().getList());
        ListView listView=findViewById(R.id.listview);
        listView.setAdapter(condAapter);
    }
    class  CondAapter extends BaseAdapter{
        List<DataList>mDataList;
        ListView listView=findViewById(R.id.listview);
        public  CondAapter(List<DataList>dataLists){
            mDataList=dataLists;
        }
        public int getCount(){
            return  mDataList.size();
        }
        public Object getItem(int i){
            return mDataList.get(i);
        }
        public  long getItemId(int i){
            return  0;

        }
        public View getView(int i, View view, ViewGroup viewGroup){

            View view1 = View.inflate(getBaseContext(),R.layout.listview_item ,null);
            DataList dataList = mDataList.get(i);

            TextView textView2 = view1.findViewById(R.id.textView2);
            TextView textView5 = view1.findViewById(R.id.textView5);
            TextView textView6 = view1.findViewById(R.id.textView6);
            TextView textView7 = view1.findViewById(R.id.textView7);
            TextView textView8 = view1.findViewById(R.id.textView8);
            TextView textView9 = view1.findViewById(R.id.textView9);

            textView2.setText(dataList.getName()+" "+" "+" "+" ");
            textView5.setText(dataList.getConadd());
            textView6.setText(dataList.getEconNum()+" "+" "+" "+" "+" "+" ");
            textView7.setText(dataList.getAsymptomNum()+" "+" "+" "+" "+" "+" ");
            textView8.setText(dataList.getDeathNum()+" "+" "+" ");
            textView9.setText(dataList.getCureNum()+" "+" "+" "+" ");
            return  view1;
        }

    }

}
